function Ellipse(origin, xRadius, yRadius) {
    this.origin = origin;
    this.xRadius = xRadius;
    this.yRadius = yRadius;
};

Ellipse.prototype = {
    constructor: Ellipse,
    getBox: function(){
        return new Rectangle(new Point(this.origin.x - this.xRadius, this.origin.y - this.yRadius),2*this.xRadius,2*this.yRadius);
    },
    getIntersectionFromCenterToPoint: function(point){
        var deltaX = point.x - this.origin.x,
            deltaY = point.y - this.origin.y;

        if (deltaX == 0 || deltaY == 0){
            return this.getBox().getIntersectionFromCenterToPoint(point);
        }

        var m = deltaY / deltaX,
            mSquared = m * m,
            xRadiusSquared = this.xRadius * this.xRadius,
            yRadiusSquared = this.yRadius * this.yRadius,
            x = Math.sqrt(1 / ((1 / xRadiusSquared) + (mSquared / yRadiusSquared)));

        if (deltaX < 0){
            x = -x;
        }


        var y = m * x;
        return new Point(this.origin.x + x, this.origin.y + y);
    }
}